<template>
  <div id="header" class="header">
    <div class="content-warpper">
      <div class="avatar">
        <img width="64" height="64" :src="seller.avatar">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}}/{{seller.deliveryTime}}分钟送达
        </div>
        <div v-if="seller.supports" class="support">
          <v-icon class="icon" :type="seller.supports[0].type" size="12px" :extra='1'></v-icon><span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="support-count" @click="showDetail">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="showDetail">
      <span class="bulletin-title"></span><span class="bulletin-text">{{seller.bulletin}}</span><i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%">
    </div>
    <transition name="fade">
      <div v-show="detailShow" class="detail">
        <div class="detail-wrapper clearfix">
          <div class="detail-main">
            <div class="name">
              {{seller.name}}
            </div>
            <div class="star-wrapper">
              <v-star :size="48" :score="seller.score"></v-star>
            </div>
            <div class="title">
              <div class="line"></div>
              <div class="text">优惠信息</div>
              <div class="line"></div>
            </div>
            <ul v-if="seller.supports" class="supports">
              <li class="support-item" v-for="(item, index) in seller.supports" :key="index">
                <v-icon class="icon" :type="seller.supports[index].type" size="16px" :extra='2'></v-icon><span class="text">{{seller.supports[index].description}}</span>
              </li>
            </ul>
            <div class="title">
              <div class="line"></div>
              <div class="text">商家公告</div>
              <div class="line"></div>
            </div>
            <div class="bulletin">
              <p class="content">
                {{seller.bulletin}}
              </p>
            </div>
          </div>
        </div>
        <div class="detail-close" @click="closeDetail">
          <i class="icon-close"></i>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import vStar from '../star/star';
import vIcon from '../icon/icon';

export default {
  name: 'header',
  props: {
    seller: {
      type: Object
    }
  },
  data() {
    return {
      detailShow: false
    };
  },
  methods: {
    showDetail() {
      this.detailShow = true;
    },
    closeDetail() {
      this.detailShow = false;
    }
  },
  components: { vStar, vIcon },
  created() {
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
  }

}
</script>

<style lang="less" scoped>
@import "../../common/styles/mixin.less";

#header {
  background-color: rgba(7, 17, 27, 0.5);
  color: #fff;
  position: relative;
  overflow: hidden;
  .content-warpper {
    position: relative;
    font-size: 0;
    padding: 24px 12px 18px 24px;
    .avatar {
      display: inline-block;
      vertical-align: top;
    }
    .content {
      vertical-align: top;
      margin-left: 16px;
      display: inline-block;
      .title {
        margin-top: 2px;
        margin-bottom: 8px;
        .brand {
          display: inline-block;
          width: 30px;
          height: 18px;
          .bg-image('../../components/header/brand');
          background-size: 30px 18px;
          background-repeat: no-repeat;
          margin-right: 6px;
          vertical-align: top;
        }
        .name {
          font-size: 16px;
          color: rgb(255, 255, 255);
          font-weight: bold;
          line-height: 18px;
        }
      }
      .description {
        margin-top: 8px;
        margin-bottom: 10px;
        font-size: 12px;
        color: rgb(255, 255, 255);
        font-weight: 200;
        line-height: 12px;
      }
      .support {
        margin-top: 10px;
        margin-bottom: 2px;
        .icon {
          margin-right: 4px;
        }
        .text {
          font-size: 10px;
          line-height: 12px;
          color: rgb(255, 255, 255);
          font-weight: 200;
        }
      }
    }
    .support-count {
      position: absolute;
      right: 12px;
      bottom: 18px;
      padding: 0 8px;
      height: 24px;
      line-height: 24px;
      background: rgba(0, 0, 0, 0.2);
      text-align: center;
      border-radius: 12px;
      vertical-align: top;
      .count {
        font-size: 10px;
        font-weight: 200;
        line-height: 12px;
      }
      .icon-keyboard_arrow_right {
        font-size: 10px;
        font-weight: 200;
        margin-left: 2px;
        line-height: 24px;
      }
    }
  }

  .bulletin-wrapper {
    line-height: 28px;
    height: 28px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 22px 0 12px;
    background-color: rgba(7, 17, 27, 0.2); // font-size: 0;
    position: relative;
    .bulletin-title {
      display: inline-block;
      width: 22px;
      height: 12px;
      background-repeat: no-repeat;
      background-size: 22px 12px;
      margin-top: 8px;
      .bg-image('../../components/header/bulletin');
      vertical-align: top;
    }
    .bulletin-text {
      vertical-align: top;
      line-height: 28px;
      font-size: 10px;
      color: rgb(255, 255, 255);
      font-weight: 200;
      margin: 0 4px;
    }
    .icon-keyboard_arrow_right {
      position: absolute;
      font-size: 10px;
      right: 12px;
      top: 8px;
    }
  }

  .background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(10px);
  }

  .fade-enter-active,
  .fade-leave-active {
    transition: opacity .5s
  }

  .fade-enter,
  .fade-leave-to {
    opacity: 0
  }

  .detail {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 100;
    overflow: auto;
    background: rgba(7, 17, 27, 0.8);
    font-size: 0;
    backdrop-filter: blur(10px);
    .detail-wrapper {
      min-width: 100%;
      min-height: 100%;
      .detail-main {
        margin-top: 64px;
        padding-bottom: 64px;
        .name {
          font-size: 16px;
          font-weight: 700;
          color: rgb(255, 255, 255);
          line-height: 16px;
          text-align: center;
        }
        .star-wrapper {
          margin-top: 16px;
          text-align: center;
          padding: 2px 0;
        }
        .title {
          display: flex;
          width: 80%;
          margin: 28px auto 24px auto;
          .line {
            flex: 1;
            position: relative;
            top: -6px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
          }
          .text {
            font-size: 14px;
            font-weight: 700;
            color: rgb(255, 255, 255);
            line-height: 14px;
            text-align: center;
            padding: 0 12px;
          }
        }
        .supports {
          width: 80%;
          margin: 0 auto;
          .support-item {
            margin-bottom: 12px;
            padding: 0 12px;
            font-size: 0;
            .text {
              font-weight: 200;
              color: rgb(255, 255, 255);
              font-size: 12px;
              line-height: 16px;
            }
            .icon {
              margin-right: 6px;
            }
          }
        }
        .bulletin {
          width: 80%;
          margin: 0 auto;
          word-break: break-word;
          .content {
            padding: 0 12px;
            font-size: 12px;
            font-weight: 200;
            color: rgb(255, 255, 255);
            line-height: 24px;
          }
        }
      }
    }

    .detail-close {
      position: relative;
      width: 32px;
      height: 32px;
      margin: -64px auto 0 auto;
      clear: both;
      font-size: 32px;
      color: rgb(255, 255, 255);
    }
  }
}
</style>